<template>
	<view class="contain">
		<!-- 统计信息 -->
		<view class="flex justify-center items-center w-[100%] mb-2 tongjititle">
			<view class="flex flex-[0.2]">
				<text>姓名</text>
			</view>
			<view class="flex flex-[0.3]">
				<text>身份证</text>
			</view>
			<view class="flex flex-[0.5]">
				<text>预约信息</text>
			</view>
		</view>
		<view class="flex justify-center items-start w-[100%] mb-2" v-if="yuyueList.data[0]!=undefined" v-for="item in yuyueList.data">
			<view class="flex justify-center flex-[0.2]">
				<text class="mid">{{item.studentname}}</text>
			</view>
			<view class="flex justify-center flex-wrap flex-[0.3] textword">
				<text class="small textword" style="width: 150rpx;">{{item.studentidcard}}</text>
			</view>
			<view class="flex w-[100%] justify-center flex-col flex-[0.5]">
				<text class="w-[100%] flex justify-center text-center small textword">{{item.appointmentthospital}}</text>
				<text class="w-[100%] flex justify-center text-center small small textword mt-1">{{item.appointmenttime}}</text>
			</view>
		</view>
		<view v-else class="flex justify-center mt-5" @click="jUrl('/pages/word/word')">
			<text>暂无体检信息, </text>
			<text class="red">点击开始预约</text>
		</view>
		
		
		
		
		
	</view>
</template>

<script setup lang='ts'>
import { ref,reactive } from 'vue'
import {  onLoad,onShow } from '@dcloudio/uni-app'
import { userStore } from '@/stores/userStore'

let { hasLogin,userData } = userStore();

let yuyueList=reactive({data:[]});

const getYuYue=()=>{
	let paraData={
		id:userData.userinfo.id,
	}
	console.log("获取预约参数:",paraData);
	uni.$tools.Reqeust('/api/getUserYuYue',paraData,'POST').then((res:any)=>{
		console.log(res);
		if(res.data.code===200){
			if(res.data.maps.carddata!=null){
				userData.bindusername=res.data.maps.carddata.account;
				userData.binduseridcard=res.data.maps.carddata.pwd;
			}else{
				console.log("用户还未绑定筛查，暂时无法获取信息")
			}
			yuyueList.data=res.data.maps.yuyueList;
		}
	});
}

//重新刷新用户信息
// const getUserInfo=()=>{
// 	uni.showLoading({
// 		title:"正在刷新.."
// 	})
// 	setTimeout(()=>{
// 		uni.hideLoading();
// 	},1000);
// 	let paraData={
// 		id:userData.userinfo.id,
// 	}
// 	console.log("重新刷新用户信息参数:",paraData);
// 	uni.$tools.Reqeust('/api/getUserInfo',paraData,'POST').then((res:any)=>{
// 		console.log(res);
// 		if(res.data.code===200){
// 			userData.userinfo=res.data.newuserinfo;
// 		}
// 	});
// }

onLoad(()=>{
	getYuYue(); //获取用户预约信息
	//getUserInfo();
});


const jUrl=(url:string,num?:number)=>{
	uni.$tools.GoUrl(url,num);
}		


</script>

<style lang='scss' scoped>
	@import "yuyue.scss";
</style>